package com.chenfan.magic.service.impl;

import com.chenfan.magic.service.IParamServiceProvider;
import lombok.AllArgsConstructor;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * @author 周夕
 * @date 2020-02-24 15:07
 */
@Service
@AllArgsConstructor
public class ParamServiceProviderImpl implements IParamServiceProvider {

    private final JdbcTemplate jdbcTemplate;

    private final String STATEMENT = "select param_value from idc_param where param_key = ? ";

    @Override
    public String get(String key) {
        try {
            Map<String, Object> paramObj = jdbcTemplate.queryForMap(STATEMENT, new String[]{key});
            return paramObj.get("param_value") + "";
        } catch (Exception ex) {
            return null;
        }
    }
}
